package com.cskaoyan.demo2.service;

import com.cskaoyan.demo2.mapper.TransferMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class TransferServiceImpl implements TransferService{

    @Autowired
    TransferMapper transferMapper;

    @Transactional
    @Override
    public void transfer(Integer from, Integer dest, Double money) {

        transferMapper.updateMoneyByName(from, money);
        //int i  = 1 / 0;
        transferMapper.updateMoneyByName(dest, -money);
    }
}
